<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>消费者首页 - 售后管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .header h1 {
            font-size: 24px;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .logout-btn {
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 8px 16px;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .nav-menu {
            background: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .nav-menu h2 {
            margin-bottom: 20px;
            color: #333;
        }

        .nav-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .nav-item {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px 20px;
            border-radius: 10px;
            text-align: center;
            cursor: pointer;
            transition: transform 0.2s ease;
            text-decoration: none;
        }

        .nav-item:hover {
            transform: translateY(-5px);
        }

        .nav-item h3 {
            font-size: 18px;
            margin-bottom: 10px;
        }

        .nav-item p {
            font-size: 14px;
            opacity: 0.9;
        }

        .stats-section {
            background: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
        }

        .stat-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
        }

        .stat-number {
            font-size: 32px;
            font-weight: bold;
            margin-bottom: 5px;
        }

        .stat-label {
            font-size: 14px;
            opacity: 0.9;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>售后管理系统 - 消费者端</h1>
        <div class="user-info">
            <span>欢迎，<span id="username">用户</span></span>
            <a href="/after_sale_system/login" class="logout-btn">退出登录</a>
        </div>
    </div>

    <div class="container">
        <div class="nav-menu">
            <h2>功能菜单</h2>
            <div class="nav-grid">
                <a href="/after_sale_system/page/consumer/applicationForm" class="nav-item">
                    <h3>提交售后申请</h3>
                    <p>创建新的售后申请</p>
                </a>
                <a href="/after_sale_system/page/consumer/applicationList" class="nav-item">
                    <h3>我的申请</h3>
                    <p>查看申请历史</p>
                </a>
                <a href="/after_sale_system/page/consumer/notifications" class="nav-item">
                    <h3>消息通知</h3>
                    <p>查看系统通知</p>
                </a>
            </div>
        </div>

        <div class="stats-section">
            <h2>统计概览</h2>
            <div class="stats-grid">
                <div class="stat-card">
                    <div class="stat-number" id="totalApplications">0</div>
                    <div class="stat-label">总申请数</div>
                </div>
                <div class="stat-card">
                    <div class="stat-number" id="pendingApplications">0</div>
                    <div class="stat-label">待处理</div>
                </div>
                <div class="stat-card">
                    <div class="stat-number" id="completedApplications">0</div>
                    <div class="stat-label">已完成</div>
                </div>
                <div class="stat-card">
                    <div class="stat-number" id="unreadNotifications">0</div>
                    <div class="stat-label">未读消息</div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 获取用户信息
        fetch('/after_sale_system/api/user/info')
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    document.getElementById('username').textContent = data.data;
                }
            })
            .catch(error => {
                console.error('获取用户信息失败:', error);
            });

        // 获取统计数据
        fetch('/after_sale_system/api/afterSale/')
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    const applications = data.data || [];
                    document.getElementById('totalApplications').textContent = applications.length;
                    
                    const pending = applications.filter(app => app.status === 'PENDING_AUDIT').length;
                    const completed = applications.filter(app => app.status === 'COMPLETED').length;
                    
                    document.getElementById('pendingApplications').textContent = pending;
                    document.getElementById('completedApplications').textContent = completed;
                }
            })
            .catch(error => {
                console.error('获取申请数据失败:', error);
            });

        // 获取未读通知数量
        fetch('/after_sale_system/api/notification/unread')
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    document.getElementById('unreadNotifications').textContent = data.data;
                }
            })
            .catch(error => {
                console.error('获取通知数据失败:', error);
            });
    </script>
</body>
</html> 